Page({
  data: {
    banners: [{
        id: 1,
        image: '/assets/1.png',
        title: 'Tech Trends 2023'
      },
      {
        id: 2,
        image: '/assets/1.png',
        title: 'Travel Destinations'
      },
      {
        id: 3,
        image: '/assets/1.png',
        title: 'Healthy Recipes'
      }
    ],
    featuredPosts: [],
    recentPosts: [],
    t: {}, // Translations
    currentLanguage: 'en'
  },


  onLoad: function () {
    // Get the first 3 posts for featured
    const featuredPosts = blogPosts.slice(0, 3);

    // Get the next 3 posts for recent
    const recentPosts = blogPosts.slice(3, 6);

    this.setData({
      featuredPosts,
      recentPosts
    });
  },

  onPostTap(e) {
    const postId = e.detail.id;
    wx.navigateTo({
      url: `/pages/post-detail/post-detail?id=${postId}`
    });
  },

  onLikeTap(e) {
    const postId = e.detail.id;
    wx.showToast({
      title: `Liked post ${postId}`,
      icon: 'success'
    });
  },

  onShareTap(e) {
    const postId = e.detail.id;
    wx.showToast({
      title: `Sharing post ${postId}`,
      icon: 'none'
    });
  },

  onBannerTap(e) {
    const bannerId = e.currentTarget.dataset.id;
    wx.showToast({
      title: `Viewing banner ${bannerId}`,
      icon: 'none'
    });
  }
})